package com.sms.businessservice.impl;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

import org.springframework.beans.BeanUtils;

import com.sms.business.Demo;
import com.sms.businessservice.DemoBusinessService;
import com.sms.dataservice.DemoDataService;
import com.sms.vo.DemoVO;

public class DemoBusinessServiceImpl implements DemoBusinessService {

	private DemoDataService demoDataService;

	public void setDemoDataService(
			DemoDataService demoDataService) {
		this.demoDataService = demoDataService;
	}

	@Override
	public void saveDemo(DemoVO demoVO) throws Exception {
		Demo demo = new Demo();
		demo.setName(demoVO.getName());
		demoDataService.saveDemo(demo);
	}

	@Override
	public List<DemoVO> fetchAllMcMembers() {
		Demo mcMembers = null;
		List<Demo> mcMembersList = new ArrayList<Demo>();
		List<DemoVO> listVO = new LinkedList<DemoVO>();
		mcMembersList = demoDataService.getMcMembers();
		Iterator<Demo> iter = mcMembersList.iterator();
		while (iter.hasNext()) {
			mcMembers = iter.next();
			DemoVO mcMembersvo = new DemoVO();
			BeanUtils.copyProperties(mcMembers, mcMembersvo);
			listVO.add(mcMembersvo);
		}
		return listVO;
	}

}
